﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;

namespace $myprojectname$.Infrastructure.Filters
{
    /// <summary>
    /// Authorize attribute implementation.
    /// </summary>
    public class Authorize : AuthorizeAttribute
    {
        public string LoginPath { get; set; }

        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            var loginUrl = "~" + this.LoginPath + "?ReturnUrl=" + filterContext.HttpContext.Request.RawUrl;
            filterContext.Result = new RedirectResult(loginUrl);
        }
    }

}
